/*****************************************************************************
Copyright 2006 Kervin L. Pierre
    EMAIL: otlkcon@adevsoft.com

This file is part of Otlkcon.

Otlkcon is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

Otlkcon is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Lesser GNU General Public License for more details.

You should have received a copy of the Lesser GNU General Public License
along with Otlkcon; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*******************************************************************************/

#include "StdAfx.h"
#include "O_IABLogon.h"
#include "O_IMsgStore.h"

extern const IID IID_IABLogon;

O_IABLogon::O_IABLogon()
{
    InitializeCriticalSection(&objectCS);
    lpMsgStore = NULL; 
}

HRESULT O_IABLogon::Create( O_IABPMsgStore *mstore )
{
    HRESULT result = S_OK;

    cRef = 1;

    OTLKCON_LOG_PRINTF(OTLKCON_LOG_LEVEL_INFO, OTLKCON_LOG_TARGET_ALL, 
        L"O_IABLogon::Create() called.\n");

    lpMsgStore = mstore;

    //memObj = mstore->memObj;

    return result;
}

HRESULT O_IABLogon::Destroy()
{
    HRESULT result = S_OK;

    return result;
}

STDMETHODIMP O_IABLogon::QueryInterface (REFIID riid, void **ppv)
{
    HRESULT result = S_OK;

    OTLKCON_LOG_PRINTF(OTLKCON_LOG_LEVEL_INFO, OTLKCON_LOG_TARGET_ALL, 
        L"inside O_IABLogon->QueryInterface. \
 {%0.8X-%0.4X-%0.4X-%0.2X%0.2X-%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X}\n",
        riid.Data1, riid.Data2, riid.Data3, riid.Data4[0], riid.Data4[1],
        riid.Data4[2], riid.Data4[3], riid.Data4[4], riid.Data4[5],
        riid.Data4[6], riid.Data4[7]);

    *ppv = NULL;

    if( memcmp(&riid, &IID_IUnknown, sizeof(IID)) &&
        memcmp(&riid, &IID_IABLogon, sizeof(IID)))
    { 
        result = ResultFromScode(E_NOINTERFACE);
        return result;
    }

    OTLKCON_LOG_PRINTF(OTLKCON_LOG_LEVEL_INFO, OTLKCON_LOG_TARGET_ALL, 
        L"\t{%0.8X-%0.4X-%0.4X-%0.2X%0.2X-%0.2X%0.2X%0.2X%0.2X%0.2X%0.2X} found\n",
        riid.Data1, riid.Data2, riid.Data3, riid.Data4[0], riid.Data4[1],
        riid.Data4[2], riid.Data4[3], riid.Data4[4], riid.Data4[5],
        riid.Data4[6], riid.Data4[7]);

    AddRef();
    *ppv = (LPVOID)this;

    return result;
}

ULONG STDMETHODCALLTYPE O_IABLogon::AddRef (void)
{
    OTLKCON_LOG_PRINTF(OTLKCON_LOG_LEVEL_INFO,  OTLKCON_LOG_TARGET_ALL, 
            L"inside O_IABLogon->AddRef()\n" );

    return ++cRef;
}

ULONG STDMETHODCALLTYPE O_IABLogon::Release (void)
{
    OTLKCON_LOG_PRINTF(OTLKCON_LOG_LEVEL_INFO,  OTLKCON_LOG_TARGET_ALL, 
            L"inside O_IABLogon->Release()\n" );

    if ( --cRef == 0 )
    {
        Destroy();
    }

    return cRef;
}

HRESULT O_IABLogon::ProcessEvent( otlkcon_event_struct *ev )
{
    HRESULT result = S_OK;

    switch( ev->eventType )
    {
        default:
            OTLKCON_DEBUGBREAK;
            break;
    }

    return result;
}

HRESULT O_IABLogon::GetLastError(   HRESULT hResult,
                                 ULONG ulFlags,  LPMAPIERROR *lppMAPIError  )
{
    HRESULT result = S_OK;

    return result;
}

HRESULT O_IABLogon::Logoff( ULONG ulFlags  )
{
    HRESULT result = S_OK;

    return result;
}

HRESULT O_IABLogon::OpenEntry( ULONG cbEntryID,  LPENTRYID lpEntryID,  
     LPCIID lpInterface,  ULONG ulFlags,  ULONG *lpulObjType,
     LPUNKNOWN *lppUnk )
{
    HRESULT result = MAPI_E_NO_SUPPORT;

    return result;
}

HRESULT O_IABLogon::CompareEntryIDs( ULONG cbEntryID1,  LPENTRYID lpEntryID1,  
     ULONG cbEntryID2,  LPENTRYID lpEntryID2,  ULONG ulFlags,
     ULONG *lpulResult  )
{
    HRESULT result = MAPI_E_NO_SUPPORT;

    return result;
}

HRESULT O_IABLogon::Advise( ULONG cbEntryID,  LPENTRYID lpEntryID,
               ULONG ulEventMask,  LPMAPIADVISESINK lpAdviseSink,
               ULONG *lpulConnection )
{
    HRESULT result = MAPI_E_NO_SUPPORT;

    return result;
}

 HRESULT O_IABLogon::Unadvise( ULONG ulConnection  )
{
    HRESULT result = MAPI_E_NO_SUPPORT;

    return result;
}

HRESULT O_IABLogon::OpenStatusEntry( LPCIID lpInterface,  ULONG ulFlags,
                        ULONG *lpulObjType,  
                        LPMAPISTATUS *lppMAPIStatus )
{
    HRESULT result = MAPI_E_NO_SUPPORT;

    return result;
}

HRESULT O_IABLogon::OpenTemplateID( ULONG cbTemplateID,  
                       LPENTRYID lpTemplateID,  
                       ULONG ulTemplateFlags,
                       LPMAPIPROP lpMAPIPropData,
                       LPCIID lpInterface,
                       LPMAPIPROP *lppMAPIPropNew,
                       LPMAPIPROP lpMAPIPropSibling )
{
    HRESULT result = MAPI_E_NO_SUPPORT;

    return result;
}

HRESULT O_IABLogon::GetOneOffTable( ULONG ulFlags,  LPMAPITABLE *lppTable )
{
    HRESULT result = MAPI_E_NO_SUPPORT;

    return result;
}

HRESULT O_IABLogon::PrepareRecips( ULONG ulFlags,  
                      LPSPropTagArray lpPropTagArray,
                      LPADRLIST lpRecipList )
{
    HRESULT result = MAPI_E_NO_SUPPORT;

    return result;
}